import {create} from 'zustand'
import {UserOrder} from '@/api/methods/orderManage/userOrder.type'

interface IOrder {
  // 用户订单数据
  orderData: UserOrder.Res.UserOrderDetail
  // 设置用户订单数据
  setOrderData: (orderData: UserOrder.Res.UserOrderDetail) => void
  // 清除用户订单数据
  clearOrderData: () => void
}

const initialOrderData = {
  orderData: {} as UserOrder.Res.UserOrderDetail
}

export const useOrderStore = create<IOrder>((set) => ({
  ...initialOrderData,
  // 设置用户订单数据
  setOrderData: (orderData) => set({orderData}),
  // 清除用户订单数据
  clearOrderData: () => set({orderData: {} as UserOrder.Res.UserOrderDetail})
}))
